sequenceDiagram
  Caller          ->>+ Resolvers: QueryResolver(repo, commit, file)
  Resolvers       ->>+ DB store: FindClosestDumps(repo, commit, file)
  DB store       -->>- Resolvers: dumps
  Resolvers      -->>- Caller: QueryResolver
  Caller          ->>+ QueryResolver: References(repo, commit, file, position, cursor)

  alt if cursor is empty
    loop for each dumps[i]
      QueryResolver     -->>+ Position adjuster: AdjustPosition(file, position, from: commit, to: dumps[i].commit)
      Position adjuster -->>- QueryResolver: adjusted file, adjusted position
      QueryResolver      ->>+ LSIF store: MonikersByPosition(dump, adjusted file, adjusted position)
      LSIF store        -->>- QueryResolver: monikers
    end

    QueryResolver    ->>+ DB store: DefinitionDumps(monikers)
    DB store        -->>- QueryResolver: definitionDumps

    Note right of Resolvers: Create curso from dumps, definitionDumps, monikers, adjusted files, adjusted positions>
  end

  loop len(locations) < limit and !cursor.RemotePhase
    QueryResolver -->>+ LSIF store: References
    LSIF store    -->>- QueryResolver: locations

    Note right of QueryResolver: Update phase, offsets in cursor
  end

  loop len(locations) < limit and cursor.RemotePhase
    QueryResolver -->>+ DB store: ReferenceIDsAndFilters
    DB store      -->>- QueryResolver: references
    QueryResolver -->>+ DB store: GetDumpsByIDs
    DB store      -->>- QueryResolver: dumps
    QueryResolver  ->>+ LSIF store: BulkMonikerResults(monikers)
    LSIF store    -->>- QueryResolver: locations

    Note right of QueryResolver: Update phase, offsets in cursor
  end

  QueryResolver     -->>+ Position adjuster: AdjustLocations(locations)
  Position adjuster -->>- QueryResolver: adjusted locations
  QueryResolver     -->>- Caller: adjusted locations, cursor
